﻿using Internal.KuiHuaBaoDian.Services.Audio;
using KuiHuaBaoDian.Services.Audio;
using System.Collections.Generic;
using UnityEngine;

namespace KuiHuaBaoDian.Services.Audio {

    public interface IAudioEvent {

        IReadOnlyList<IAudioContainer> Containers { get; }

        AudioPlayMode PlayMode { get; }

        IAudioMixer Mixer { get; }

        IAudioModifier Modifier { get; }
    }

    public abstract class KHBD_AudioEvent : ScriptableObject, IAudioEvent, IAudioEventInternal {

        protected KHBD_AudioEvent() : base() { }

        [SerializeField]
        private KHBD_AudioContainer[] m_Containers = new KHBD_AudioContainer[0];
        public IReadOnlyList<IAudioContainer> Containers => m_Containers;

        [SerializeField]
        private AudioPlayMode m_PlayMode;
        public AudioPlayMode PlayMode => m_PlayMode;

        [SerializeField]
        private KHBD_AudioMixer m_Mixer;
        public IAudioMixer Mixer => m_Mixer;

        [SerializeField]
        private KHBD_AudioModifier m_Modifier = new();
        public IAudioModifier Modifier => m_Modifier;

        void IAudioEventInternal.SetContainers(KHBD_AudioContainer[] containers) {
            m_Containers = containers;
        }

        void IAudioEventInternal.SetPlayMode(AudioPlayMode playMode) {
            m_PlayMode = playMode;
        }

        void IAudioEventInternal.SetMixer(KHBD_AudioMixer mixer) {
            m_Mixer = mixer;
        }
    }
}

namespace Internal.KuiHuaBaoDian.Services.Audio {

    public interface IAudioEventInternal {

        void SetContainers(KHBD_AudioContainer[] containers);

        void SetPlayMode(AudioPlayMode playMode);

        void SetMixer(KHBD_AudioMixer mixer);
    }
}
